package sunwin.yoms.service.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sunwin.yoms.comm.YomsException;
import sunwin.yoms.dao.StadiumGroupDao;
import sunwin.yoms.domain.resource.StadiumGroupDomain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by watson on 2015/7/30.
 */
@Service
public class StadiumGroupService {
    @Autowired
    private StadiumGroupDao stadiumGroupDao;

    //查询
    public List<StadiumGroupDomain> getStadiumGroup(StadiumGroupDomain stadiumGroupDomain) {
        List<StadiumGroupDomain> stadiumGroupDomains = new ArrayList<StadiumGroupDomain>();
        stadiumGroupDomains = stadiumGroupDao.getDomainCollection(stadiumGroupDomain);
        return stadiumGroupDomains;
    }

    //id查询
    public StadiumGroupDomain getStadiuGroupById(int stadiumGroupId) {
        return stadiumGroupDao.getDomainById(stadiumGroupId);
    }

    //总数量
    public int getStadiumGroupCount() {
        return stadiumGroupDao.getDomainCount();
    }

    //增加
    public void addStadiumGroup(StadiumGroupDomain stadiumGroupDomain) throws YomsException {
        if (stadiumGroupDao.addDomain(stadiumGroupDomain) != 1) {
            throw new YomsException("增加公园场馆分组失败");
        }
    }

    //删除
    public void deleteStadiumGroup(StadiumGroupDomain stadiumGroupDomain) throws YomsException {
        if (stadiumGroupDao.deleteDomain(stadiumGroupDomain) != 1) {
            throw new YomsException("删除公园场馆分组失败");
        }
    }

    //更新
    public void upStadiumGroup(StadiumGroupDomain stadiumGroupDomain) throws YomsException {
        if (stadiumGroupDao.updateDomain(stadiumGroupDomain) != 1) {
            throw new YomsException("更新公园场馆分组失败");
        }
    }
}
